import path from  'path';
import fs from  'fs'
import Root from  './Root.js'
export default   class  NodeRoot extends Root{
    constructor(){
        super()
    }
      load(dir){
          return new Promise(function (resolve, reject) {
              fs.readFile(path.resolve()+'/lib/'+dir+".jsr", function(err, data) {
                  if (err) {
                      reject(e);
                  } else {
                      //  console.log(data);
                      resolve(data);
                  }
              });
          });
    }
    save(dir,data){
        return new Promise(function (resolve, reject) {
            fs.writeFile(dir,data,{flag:"a"},function (err) {
                if (err) {
                    reject(e);
                } else {
                    //  console.log(data);
                    resolve(data);
                }
            })

        });
    }

}